﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using System.Diagnostics;
using System.Net;

namespace IntelligentDecisioning.SharePoint.Helpers
{
    public class CommonFunctions
    {
        #region Configuration

        const String CONFIG_LIST = "IntelligentDecisioning.SharePoint.Configuration";
 
        static SPList EnsureConfigurationList(SPWeb web)
        {
            if (web != null)
            {
                SPList configList = web.Lists[CONFIG_LIST];
                if (configList == null)
                {
                    configList = CreateConfigList(web);
                }
                return configList;
            }
            else
            {
                throw new ArgumentNullException("SPWeb");
            }
        }

        private static SPList CreateConfigList(SPWeb web)
        {
            return null;
        }

        #endregion

        #region Internet Access


        public static bool IsConnectedToInternet()
        {
            bool isConnected = false;

            try
            {
                IPHostEntry host;
                host = Dns.GetHostEntry("id-crm.com");
                isConnected = true;
            }
            catch(Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return isConnected;
        }

        #endregion
    }
}
